#include "util_api.h"
#include <pthread.h>

uint32_t u32_log_level_ctrl = INFO_LEVEL;

int MID_UTIL_CreateDetachThread(ThreadEntryPtrType entry, void *para, pthread_t *pid)
{
    pthread_t ThreadId;
    pthread_attr_t attr;

    pthread_attr_init(&attr);
    pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
    if(pthread_create(&ThreadId, &attr, entry, para) == 0) {
        pthread_attr_destroy(&attr);
		if(pid)
			*pid = ThreadId;
		return 0;
    }
    pthread_attr_destroy(&attr);
    return -1;
}

void MID_UTIL_Print_Buf(unsigned char* da ,int len)
{
	printf("---BUFFER PRINT(len %d)--\n", len);
	for(int i=0;i<len;i++ )printf("%02x ",da[i]);
	printf("\n");
}
